from rest_framework.generics import CreateAPIView, RetrieveAPIView, RetrieveUpdateAPIView, ListAPIView, DestroyAPIView

from comment.models import Comment
from comment.serializer import CommentDetailSer, CommentQuestionSer, CommentAnswerSer, CommentUpdateSer


class CommentQuestionView(CreateAPIView):
    serializer_class = CommentQuestionSer

    def perform_create(self, serializer):
        serializer.save(creator=self.request.user)


class CommentAnswerView(CreateAPIView):
    serializer_class = CommentAnswerSer

    def perform_create(self, serializer):
        serializer.save(creator=self.request.user)


class CommentDetailView(RetrieveAPIView):
    serializer_class = CommentDetailSer
    queryset = Comment.objects.all()


class CommentUpdateView(RetrieveUpdateAPIView):
    serializer_class = CommentUpdateSer
    queryset = Comment.objects.all()


class CommentListView(ListAPIView):
    serializer_class = CommentDetailSer
    queryset = Comment.objects.all()


class CommentDeleteView(DestroyAPIView):
    serializer_class = CommentUpdateSer
    queryset = Comment.objects.all()
